package com.qxsx.midi.activity.me;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.base.BaseActivity;
import com.qxsx.midi.utils.MyNet;
import com.qxsx.midi.utils.callBackJsonArray;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2015/11/27.
 */
public class MeMessageActivity extends BaseActivity {
    private TextView tv_message, tv_time;
    String id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_details);
        setNavBtn(R.mipmap.back, 0);
        setTitle("消息详情");
        Intent intent = getIntent();
        id = intent.getStringExtra("id");//得到ID

        findById();
        Initdata();

    }

    private void Initdata() {

        JSONObject object = new JSONObject();
        JSONArray array = new JSONArray();

        try {
            object.put("id", id);
            array.put(object);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        MyNet.doPostJsonArray("114", array, new callBackJsonArray() {
            @Override
            public void run(Object code, Object message, JSONArray array) {
                try {
                    JSONObject object1 = array.getJSONObject(0);
                    String message_cotent = object1.getString("message_cotent");
                    String message_time = object1.getString("message_time");
                    tv_message.setText(message_cotent);
                    tv_time.setText(message_time);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });


    }

    private void findById() {
        tv_message = (TextView) findViewById(R.id.tv_message);
        tv_time = (TextView) findViewById(R.id.tv_time);

    }

    @Override
    protected void HandleTitleBarEvent(BaseActivity.TitleBar component, View v) {
        switch (component) {
            case LEFT:
                finish();
                break;

        }
    }
}
